package com.holic.spring.custom.controller;

import com.holic.spring.aigc.client.SparkClient;
import com.holic.spring.aigc.model.spark.SparkMessage;
import com.holic.spring.aigc.model.spark.SparkRequest;
import com.holic.spring.aigc.model.spark.SparkResponse;
import com.holic.spring.custom.annotation.GraphQLComponent;
import com.holic.spring.custom.annotation.GraphQLMapping;
import graphql.com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName ProjectController
 * @Description
 * @Author Neil
 * @Date 2024/11/12 13:53
 * @Version V1.0
 **/
@GraphQLComponent
@Controller
public class ProjectController {

    @Autowired
    SparkClient sparkClient;

    @GraphQLMapping
    public String getProject(HttpServletRequest request) {
        SparkRequest sparkRequest = SparkRequest.builder()
                .messages(Lists.newArrayList(SparkMessage.builder().role("user").content("今天是几号").build()))
                .build();
        SparkResponse response = sparkClient.request(sparkRequest);
        return response.getChoices().get(0).getMessage().getContent();
    }

}
